<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ page import="org.apache.commons.fileupload.FileItem" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.commons.fileupload.*" %>
<%@ page import="org.apache.commons.fileupload.disk.*" %>
<%@ page import="org.apache.commons.fileupload.servlet.*" %>
<%@ page import="org.apache.commons.io.*" %>
<%@ page import="java.io.*" %>     
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<script type="text/javascript">

  function ValidarCampos(){
	  if(document.getElementById("nombre").value==""){
		  alert("Debe rellenar el campo Nombre");
	  }else{
		  if(document.getElementById("email").value==""){
			  alert("Debe rellenar el campo Email");
		  }else{
			  if(document.getElementById("fichero").value==""){
				  alert("Debe rellenar el campo Fichero");
			  }else{
			  	  document.getElementById("f1").submit();
			  }
		  }
	  }
  }
</script>
</head>
<body>
<%
String nombre="";
String email="";
String fichero="";
if (request.getAttribute("nombre")!=null){
	nombre=request.getAttribute("nombre").toString();
}
if (request.getAttribute("email")!=null){
	email=request.getAttribute("email").toString();
}
if (request.getAttribute("fichero")!=null){
	fichero=request.getAttribute("fichero").toString();
}
%>
	<form id="f1" action="SubidaFichero" method="post" enctype="multipart/form-data">
		<input id="nombre" type="text" name="nombre" value="<%=nombre %>" placeholder="Escribe tu nombre"/><br/>
		<input id="email" type="email" name="email" value="<%=email %>" placeholder="Escribe tu email"/><br/>
		<input id="fichero" type="file" name="fichero" accept="application/pdf"/><br/>
		<input type="button" value="Enviar por POST" onclick="ValidarCampos();"/> 		
		<span><%=fichero %></span><br/>
		<object data="tmp/<%=fichero %>" type="application/pdf" width="500px" height="700px">
    		<embed src="tmp/<%=fichero %>" type="application/pdf" width="500px" height="700px"/>
		</object>
	</form>
	<embed src="C:\Users\curso\Desktop\sql tiradas.txt" width="500" height="375"></embed>
</body>
</html>